package com.xbongbong.paas.model.impl;

import com.xbongbong.paas.model.FineClueConsumptionModel;
import com.xbongbong.paas.toolbox.util.CollectionsUtil;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import com.xbongbong.pro.domain.dao.FineClueConsumptionDao;
import com.xbongbong.pro.domain.entity.FineClueConsumptionEntity;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/***
 * 精线索用量impl
 * @author hongxiao
 * @date 2021-12-29 23:25
 */
@Service("fineClueConsumptionModel")
public class FineClueConsumptionModelImpl implements FineClueConsumptionModel {
    @Resource
    private FineClueConsumptionDao fineClueConsumptionDao;

    @Override
    public Integer insert(FineClueConsumptionEntity entity) {
        Long now = DateTimeUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return fineClueConsumptionDao.insert(entity);
    }

    @Override
    public void insertBatch(List<FineClueConsumptionEntity> list) {
        if (CollectionsUtil.isNotEmpty(list)){
            fineClueConsumptionDao.insertBatch(list);
        }
    }

    @Override
    public List<FineClueConsumptionEntity> findEntitys(Map<String, Object> param) {
        return fineClueConsumptionDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return fineClueConsumptionDao.getEntitysCount(param);
    }

    @Override
    public Integer update(FineClueConsumptionEntity entity) {
        Long now = DateTimeUtil.getInt();
        entity.setUpdateTime(now);
        return fineClueConsumptionDao.update(entity);
    }

    @Override
    public void updateBatch(List<FineClueConsumptionEntity> list, String corpid) {
        if (CollectionsUtil.isNotEmpty(list)){
            fineClueConsumptionDao.updateBatch(list, corpid);
        }
    }

    @Override
    public Integer save(FineClueConsumptionEntity entity) {
        if (entity.getId() == null || entity.getId().equals(0L)) {
            return insert(entity);
        }
        return update(entity);
    }


    @Override
    public FineClueConsumptionEntity getByKey(Long key, String corpid) {
        return fineClueConsumptionDao.getByKey(key, corpid);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return fineClueConsumptionDao.findEntitys(param);
    }

    @Override
    public FineClueConsumptionEntity getByPid(String corpid, String pid, Integer source) {
        return fineClueConsumptionDao.getByPid(corpid, pid, source);
    }

    @Override
    public List<String> getPidsByDataIdIn(String corpid, List<Long> dataIdIn, Integer businessType, Integer status, Integer source) {
        if (CollectionsUtil.isEmpty(dataIdIn)) {
            return null;
        }
        return fineClueConsumptionDao.getPidsByDataIdIn(corpid, dataIdIn, businessType, status, source);
    }

    @Override
    public Integer updateStatusByPids(String corpid, List<String> pids, Integer status, Integer source) {
        if (CollectionsUtil.isEmpty(pids)) {
            return null;
        }
        return fineClueConsumptionDao.updateStatusByPids(corpid, pids, status, source);
    }

    @Override
    public List<String> getCorpidList() {
        return fineClueConsumptionDao.getCorpidList();
    }

    @Override
    public List<FineClueConsumptionEntity> getPidsByDataIdEmpty(String corpid) {
        return fineClueConsumptionDao.getPidsByDataIdEmpty(corpid);
    }
}
